package com.atguigu.gmall.cart.mapper;

import com.atguigu.gmall.model.cart.CartInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/***
 * 购物车dao层映射
 */
@Mapper
public interface CartInfoMapper extends BaseMapper<CartInfo> {
    /**
     * 全选
     *
     * @param username
     * @param status
     * @return
     */
    @Update("update cart_info set is_checked=#{status} where user_id=#{username}")
    int checkAll(@Param("username") String username,
                 @Param("status") Short status);

    /**
     * 选单个
     * @param username
     * @param id
     * @param status
     * @return
     */
    @Update("update cart_info set is_checked=#{status} where user_id=#{username} and id=#{id}")
    int checkOne(@Param("username") String username,
                 @Param("id") Long id,
                 @Param("status") Short status);
}
